import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.*;

public class T3 extends JFrame implements ItemListener
{
    JLabel label;
    JComboBox choiceColor;
    JPanel panel;
    JTextArea textContent;
    T3(String s) {
        super(s);
        setBackground(Color.cyan);
        panel = new JPanel();
        label = new JLabel("选择成绩段");
        choiceColor = new JComboBox();
        choiceColor.addItem("90-100");
        choiceColor.addItem("80-90");
        choiceColor.addItem("70-80");
        choiceColor.addItem("60-70");
        choiceColor.addItem("60以下");
        panel.add(label);
        panel.add(choiceColor);
        choiceColor.addItemListener(this);
        textContent = new JTextArea();
        getgradestatue();

        add(panel,BorderLayout.NORTH);
        add(textContent,BorderLayout.CENTER);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100,100,200,200);
        setVisible(true);
        validate();
    }
    public void itemStateChanged(ItemEvent e)
    {
        getgradestatue();
    }

    private void getgradestatue() {
        int s = (int) choiceColor.getSelectedIndex();
        if(s==0){
            textContent.setText("优秀");
        }
        if(s==1){
            textContent.setText("良好");
        }
        if(s==2){
            textContent.setText("中等");
        }
        if(s==3){
            textContent.setText("及格");
        }
        if(s==4){
            textContent.setText("不及格");
        }
    }
    public static void main(String[] args) {
        T3 a=new T3("T3");
    }

}
